using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using GraphAlgsPresentation.Core;

namespace GraphAlgsPresentation.ScriptLibrary
{
    /// <summary>
    /// Represents a windows form of ScriptVisualizer
    /// </summary>
    public partial class frmScriptVisualizer : Form
    {
        /// <summary>
        /// Sets the script.
        /// </summary>
        /// <value>The script.</value>
        public VisualScript Script
        {
            set
            {
                this.graphPlotter1.LayoutContext = value.LayoutContext;
                Context tmp = new Context();
                tmp.LayoutContext = value.LayoutContext;
                tmp.CommentControl = this.commentControl1;
                foreach (List<Command> lstCmd in value.Commands)
                    foreach (Command cmd in lstCmd)
                    {
                        if (cmd is Delay) continue;
                        cmd.Context = tmp;
                        cmd.Run();
                    }
                this.graphPlotter1.Draw();
            }
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="frmScriptVisualizer"/> class.
        /// </summary>
        public frmScriptVisualizer()
        {
            InitializeComponent();
        }
    }
}